import * as service from "@/service";
import { IMon1, IMon2 } from "./interface";

const mon1: IMon1 = {
  namespaced: true,
  state: {
    states: [],
  },
  actions: {
    async getmon1({ commit }) {
      const res = await service.mon1();
      const action = {
        type: "GET_MON",
        res: res,
      };
      commit(action);
    },
  },
  mutations: {
    GET_MON(state, { res }) {
      state.states = res;
    },
  },
};
const mon2: IMon2 = {
  namespaced: true,
  state: {
    states: [],
  },
  actions: {
    async getmon2({ commit }, { params }) {
      console.log(params);

      const res = await service.mon2(params.categoryId);
      const action = {
        type: "GET_MON",
        res: res,
      };
      commit(action);
    },
  },
  mutations: {
    GET_MON(state, { res }) {
      state.states = res;
    },
  },
};
export { mon1, mon2 };
